<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>index</title>
    <style>
        /* html,body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
    
        body {
            display: flex;
            align-items: center; 
            justify-content: center; 
        }
        .content {
            width: 300px;
            height: 300px;
            background: orange;        
        } */
        .container {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}
.list {
    background-color: skyblue;
    margin: 10px;
}
/* 最后一项margin-right:auto */
.list:last-child {
    margin-right: auto;
}
    </style>
</head>
<body>
    <div class="container">
        <div class="list"></div>
        <div class="list"></div>
        <div class="list"></div>
        <div class="list"></div>
        <div class="list"></div>
        <div class="list"></div>
        <div class="list"></div>
    </div>
    <!-- <div class="content"></div> -->
</body>

<script type="text/javascript">
    //   var jsonDic = {"userlist":[{"userid":"POLICE_9001","playurl":"room:\/\/49.232.85.131:1935\/webrtc\/1400375986_827_POLICE_9001_main"}],"userlist_aux":[]}
    //   let newUserList = ''
    //   console.log('onWebRTCUserListPush.jsonDict:', jsonDic)
    //   newUserList = jsonDic.userlist
    //   // console.log('=== newUserList: ', JSON.stringify(newUserList))
    //   console.log('=== newUserList: ', newUserList, typeof newUserList)

    //   let pushers = []
    //   newUserList && newUserList.forEach(function (val) {
    //     const pusher = {
    //       userID: val.userid,
    //       accelerateURL: val.playurl
    //     }
    //     pushers.push(pusher)
    //   })

//     给定一个整数数组（有正数有负数），找出总和最大的连续数列，并返回总和。
// 示例：
// 输入： [-2,1,-3,4,-1,2,1,-5,4]
// 输出： 6
// 解释： 连续子数组 [4,-1,2,1] 的和最大，为 6。
function getSequenceArr(arr) {
    let arrCopy = []
    let sum = 0
	let max = 0
    if (arr.length < 0) {
        return ([], 0)
    } else {
        arr.forEach(element => {
            if (sum < 0) {
                sum = element
                arrCopy = []
            } else {
                sum += element
                arrCopy.push(element)
            }

            if (sum > max) {
                max = sum
            }
        })
        return (arrCopy, sum)
    }
}
let arrList = [-2,1,-3,4,-1,2,1,-5,4]
getSequenceArr(arrList)
</script>
</html>